#include "include/Point.hpp"
#include <iostream>
#include <stdio.h>

Point::Point(unsigned long idx, std::initializer_list<double> ord, bool boundary)
{
    index = idx;
    int cnt = 0;
    for(auto iter=ord.begin(); iter<ord.end(); iter++)
    {
       cord.push_back(*iter);
       cnt += 1;   
    }
    marker = boundary;
}

void Point::set_marker(bool m)
{
    marker = m;
}

double Point::operator[](unsigned int i)
{
    if(i <= 1)
    {
        return cord[i];
    }
    else
    {
        std::cerr << "Abort for illegal index of Point[" << i << "]" << std::endl;
        abort();
        return 0;
    }
}

std::ostream& operator<<(std::ostream& os, Point p)
{
    os <<"Point" << id(p)  <<"(" << p[0] <<", " << p[1] << ") " << p.marker << std::endl;
    return os;
}

unsigned long id(Point p)
{
    return p.index;
}

bool is_boundary(Point p)
{
    return p.marker;
}
